<div class="container_12 content-wrapper">
	<div class="grid_9">
    <h2>My Appointments</h2>
    <a href="<?php echo site_url('home/add_booking');?>" class="ibtn add">Add Appointments</a>
    	<?php flash();?>
	<?php
	
	if(!empty($appointments)){
	$tmpl = array ( 'table_open'  => '<table border="1" cellpadding="2" cellspacing="1" class="tbl-list" id="my-appointments">' );
	$this->table->set_heading('Service', 'Stylist', 'Status', 'Date', 'Time', 'Action');
	$this->table->set_template($tmpl);
	
	foreach($appointments as $v){
		if($v->status == 'Pending'){
			$link = '<a href="'.site_url('home/delete/booking/'.$v->id).'" class="btn-icon delete" title="Delete">Delete</a>
				';
		}
		else {
			if($v->status == 'Deny'){
				$message = 'Booking Has been denied';	
			}
			else if ($v->status == 'Confirmed'){
				$message = 'Your appointment has been confirmed <br/><a href="'.site_url('home/chat/'.$v->id.'/'.$v->s_id.'/'.$v->userid).'" class="btn-icon chat" target="_blank" title="Chat with stylist">Chat</a>';
			}
			$link = $message;	
		}
			
		
		$data = array(
				$v->service,
				$v->sfname.' '.$v->slname,
				$v->status,
				$v->appointment_date,
				date('g:i A', strtotime($v->aps_time_from)).'-'.date('g:i A', strtotime($v->aps_time_to)),
				$link

		);
		$this->table->add_row($data);	
	}
	echo $this->table->generate();
	}
	else {
		echo '<div class="msg notice"><span></span><h5>Notice</h5>No Appointments made yet.</div>';	
	}
?>
    </div>
	 <div class="grid_3">
    	<?php echo $this->load->view('layouts/menu/_customer', TRUE);?>
    </div>
</div>